/*
 * RhoStat.h
 *
 *  Created on: Aug 12, 2013
 *      Author: marchi
 */

#ifndef RHOSTAT_H_
#define RHOSTAT_H_

#include "Rho.h"
#include "histograms.hpp"
struct op_PickPlane{
	vector<int> Axis;
	op_PickPlane(){Axis=vector<int>(DIM);Axis[XX]=XX;Axis[YY]=YY;Axis[ZZ]=ZZ;}
	vector<int> & operator()(char c){
		switch(c){
		case 'X':
			Axis[XX]=XX;Axis[YY]=YY;Axis[ZZ]=ZZ;
			break;
		case 'Y':
			Axis[XX]=YY;Axis[YY]=ZZ;Axis[ZZ]=XX;
			break;
		case 'Z':
			Axis[XX]=ZZ;Axis[YY]=YY;Axis[ZZ]=XX;
			break;
		default:
			Axis[XX]=XX;Axis[YY]=YY;Axis[ZZ]=ZZ;
			break;
		}
		return Axis;
	};

};
class RhoStat: public Rho {
	static int count;
	static int count1D;
	static int count2D;
	static int firstcall3D;
	static int firstcall2D;

	Histogram1D h1D;
	Histogram2D h2D;
	vector<int> triad;
	double cut3D,cut2D;
	Matrix coGrid,ocGrid;

public:
	RhoStat();
	virtual void Density(MAtoms & at){
		Rho::Density(at,false);
		count++;
	}
	virtual void DensityRot(MAtoms & at){
		Rho::DensityRot(at);
		count++;
	}
	virtual Histogram1D DensityP1D(double,double);
	virtual Histogram2D DensityP2D(double, double,double, double);
	virtual Histogram3D Density3D(double, double);
	virtual void zero(){(*this)[0]=0.0;count=0;}
	RhoStat & doStat(){
		(*this)/=static_cast<double>(count);
		return *this;
	}
	void sHistAxis(char c){
		triad=op_PickPlane()(c);
		h2D.sTags(triad);
	}
	virtual ~RhoStat();
};

#endif /* RHOSTAT_H_ */
